import request from './request';
import type { WritingMaterialAccumulation, ApiResponse } from '@/types/accumulation';

// 获取作文素材列表
export function getWritingMaterials() {
  return request({
    url: '/api/writing-material-accumulation/list',
    method: 'get',
  });
}

// 新增作文素材
export function addWritingMaterial(data: WritingMaterialAccumulation) {
  return request<ApiResponse<WritingMaterialAccumulation>>({
    url: '/api/writing-material-accumulation/add',
    method: 'post',
    data
  });
}

// 更新作文素材
export function updateWritingMaterial(data: WritingMaterialAccumulation) {
  return request<ApiResponse<WritingMaterialAccumulation>>({
    url: '/api/writing-material-accumulation/update',
    method: 'put',
    data
  });
}

// 删除作文素材
export function deleteWritingMaterial(id: number) {
  return request<ApiResponse<void>>({
    url: `/api/writing-material-accumulation/delete/${id}`,
    method: 'delete'
  });
}

// 批量删除作文素材
export function batchDeleteWritingMaterials(ids: number[]) {
  return request<ApiResponse<void>>({
    url: '/api/writing-material-accumulation/delete/batch',
    method: 'delete',
    data: ids
  });
}

// 根据ID获取作文素材详情
export function getWritingMaterialById(id: number) {
  return request<ApiResponse<WritingMaterialAccumulation>>({
    url: `/api/writing-material-accumulation/${id}`,
    method: 'get'
  });
}